package xp2p.test.integration.files;

import java.io.File;
import java.net.URI;
import java.util.logging.Logger;
import net.jxta.peergroup.PeerGroup;
import net.jxta.platform.NetworkManager;
import xp2p.conf.BasicConfiguration;
import xp2p.svc.file.FilePublisher;

public class FileSource
{
	public static void  main(String[] args) 
	{
		try
		{
			BasicConfiguration conf = new BasicConfiguration();
			conf.StartURI = new URI("tcp://localhost:9701");
			NetworkManager nm = conf.Build();
			nm.startNetwork();			
			Logger log = Logger.getLogger("Main");
			Thread.sleep(10000); // sleep for 10 secs
			PeerGroup group = nm.getNetPeerGroup();
			FilePublisher publisher = new FilePublisher();
			publisher.setGroup(group);
			publisher.setPropagate(false);
			publisher.AddFile("123", new File("C:\\Users\\1\\Desktop\\123123.txt"));
			Thread t = new Thread(publisher);
			t.start();
			Thread.sleep(2100000); // sleep for 10 secs
			t.interrupt();
			Thread.sleep(10000); // sleep for 10 secs
			nm.stopNetwork();			
		} catch (Exception e)
		{
			// TODOL Auto-generated catch block
			e.printStackTrace();
		}		
	}
}
